package com.j.lemon.learn.basic.httpClient;//package com.lemon.httpClient;
//
//
//import com.mysql.cj.x.protobuf.MysqlxExpect;
//import org.apache.http.HttpEntity;
//import org.apache.http.NameValuePair;
//import org.apache.http.client.HttpClient;
//import org.apache.http.client.config.RequestConfig;
//import org.apache.http.client.entity.UrlEncodedFormEntity;
//import org.apache.http.client.methods.CloseableHttpResponse;
//import org.apache.http.client.methods.HttpGet;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.impl.client.HttpClients;
//import org.apache.http.message.BasicNameValuePair;
//import org.apache.http.util.EntityUtils;
//import org.apache.poi.ss.usermodel.Workbook;
//import org.apache.poi.xssf.usermodel.XSSFWorkbook;
//import org.junit.jupiter.api.Test1;
//
//import java.io.*;
//import java.nio.file.Files;
//import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.List;
//
//class HttpClientUtils {
//    @Test1
//    void test1() throws IOException {
//        //创建httpclient
//        CloseableHttpClient httpClient = HttpClients.createDefault();
//        //
//        List<NameValuePair> list = new ArrayList<>();
//        //两种entity
//        list.add(new BasicNameValuePair("username","zhangsan"));
//        list.add(new BasicNameValuePair("partner_code","shtxdev"));
//        list.add(new BasicNameValuePair("partner_key","12752qw196014AFFE5729CC500Ef396"));
//
//        list.add(new BasicNameValuePair("app_type","file"));
//
//        list.add(new BasicNameValuePair("file_name","副本配合测试名单-不良.xlsx"));
//        list.add(new BasicNameValuePair("uuid_name","4b20b4c3fe7d45e8827dcd57eb016608.xlsx"));
//
//        UrlEncodedFormEntity encodedFormEntity = new UrlEncodedFormEntity(list,"utf-8");
////        StringEntity stringEntity = new StringEntity("123");
////        stringEntity.setContentType("application/json");
//        HttpPost httpPost=new HttpPost("https://apiqa.st-creditech.com/file/external/fileDownload");
//        RequestConfig config = RequestConfig.custom().setSocketTimeout(1000).setConnectTimeout(2000).build();
//        httpPost.setEntity(encodedFormEntity);
//        httpPost.setConfig(config);
//        CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
//        HttpEntity entity=httpResponse.getEntity();
////        String res = EntityUtils.toString(entity,"utf-8");
////        System.out.println(res);
//
//        InputStream content = entity.getContent();
//        File file = new File("/Users/lijunjun/qweqwe.xlsx");
//        if(!file.exists()){
//            file.createNewFile();
//        }
//        OutputStream outputStream = Files.newOutputStream(file.toPath());
//
//
//        Workbook workbook = new XSSFWorkbook(content);
//        workbook.write(outputStream);
//
//        //get
////        HttpGet httpGet = new HttpGet("http://www.baidu.com");
////        CloseableHttpResponse response = httpClient.execute(httpGet);
////        HttpEntity entity=httpResponse.getEntity();
////        String res = EntityUtils.toString(entity,"utf-8");
////        System.out.println(res);
//
////        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(entity.getContent(),"utf-8"));
////        StringBuilder stringBuilder = new StringBuilder();
////        String len =null;
////        while((len=bufferedReader.readLine())!=null){
////            stringBuilder.append(len);
////        }
////        System.out.println(stringBuilder);
//
//
//
//    }
//    @Test1
//    void test2(){
////        System.out.println(Character.forDigit((124 & 240)>>4,16));
////        System.out.println(17>>4);
////        System.out.println(2 & 240);
//        System.out.println(123&15);
//    }
//}
